⚡ Bolt: [성능 개선] 반복 호출되는 함수 외부로 불변 문자열 및 해시 연산 이동 - #275
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes the html4tree Kotlin CLI’s hot path (process_dir) by hoisting large invariant CSS strings and the SHA-256 style hash computation out of the repeatedly-invoked function and into file-level private vals, reducing per-directory allocations and CPU work.
Changes:
- Hoisted
cssContent,css, andstyleHashfrom insideprocess_dirto top-levelprivate valdeclarations. - Updated the Jules “bolt” learning log with an entry documenting this hoisting optimization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/main/kotlin/html4tree/main.kt | Hoists static CSS strings and SHA-256 hash computation out of process_dir to reduce repeated work. |
| .jules/bolt.md | Adds a new performance-learning entry documenting the hoisting approach. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private val css = """ | ||
| <style> | ||
| ${cssContent} </style> | ||
| """ |
|
Closing as superseded by canonical #363. The same stylesheet and SHA-256 work is hoisted there together with exact emitted-byte CSP correctness, an independent real generated-file digest regression, APA 7 doctoring, |
Understood. Acknowledging that this work is superseded and stopping work on this task. |
💡 What:
process_dir함수 내부에 있던cssContent,css불변 문자열 및styleHash(SHA-256 연산) 값을 함수 외부 최상단private val로 이동 (호이스팅)시켰습니다.🎯 Why:
process_dir함수는 디렉토리 순회 중 반복적으로 호출되는 핫 패스(hot path)입니다. 내부에 거대한 정적 문자열 할당과 값비싼 SHA-256 암호화 해시 연산이 위치하면 매 호출마다 불필요한 메모리 할당과 CPU 오버헤드가 지속적으로 발생합니다.📊 Impact: 디렉토리를 탐색할 때마다 발생하던 큰 문자열 재할당과 SHA-256 암호화 해시 계산을 단 1회(클래스 로딩 시)로 줄여 CPU 리소스 소모 및 GC(Garbage Collection) 부하를 획기적으로 개선합니다.
🔬 Measurement: 전체 테스트 스위트를 실행하여(
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 && ./gradlew clean test jacocoTestReport jacocoTestCoverageVerification --continue) 성능 최적화 후에도 기능 및 100% 코드 커버리지가 동일하게 유지됨을 확인하였습니다.PR created automatically by Jules for task 680193654362436127 started by @seonghobae